/***
 * 类似依赖注入模式
 */
class ICommand {
    
    execute(){

    }
}
class Iplayer {
    // play
    // pause
    // stop
    // speed
}
/***
 * 播放器
 * Receiver 经常变动
 */
class Player extends Iplayer{
    play(){
        console.log("播放");
    }
    pause(){
        console.log("暂停");
    }
    stop(){
        console.log("停止");
    }
    speed(){
        console.log("加速");
    }
}


class PauseCommand extends ICommand{
    constructor(player){
        super()
        this.player = player
    }
    execute(){
        this.player.pause()
    }
}
class PlayCommand extends ICommand{
    constructor(player){
        super()
        this.player = player
    }
    execute(){
        this.player.play()
    }
}
class StopCommand extends ICommand{
    constructor(player){
        super()
        this.player = player
    }
    execute(){
        this.player.stop()
    }
}
class SpeedCommand extends ICommand{
    constructor(player){
        super()
        this.player = player
    }
    execute(){
        this.player.speed()
    }
}

class Controler {
    constructor(){
        this.commandes = []
    }
    addCommond(cmd){
        this.commandes.push(cmd)
    }
    execuse(cmd){
        cmd.execuse()
    }
    /***
     * 命令集
     */
    execuses(){
        commandes.forEach(cmd => {
            cmd.execuse()
        });
        this.commandes = []
    }

}

const player = new Player()
// const mp4Player = new Player()
const ctr = new Controler()
ctr.execuse(new PlayCommand(player))
// ctr.addCommond(new PlayCommand(player))
// ctr.addCommond(new PauseCommand(player))
// ctr.addCommond(new StopCommand(player))
// ctr.addCommond(new SpeedCommand(player))
// ctr.execuses()

